<!DOCTYPE html>
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<title>基础知识</title>
	<link href="https://cdn.bootcdn.net/ajax/libs/twitter-bootstrap/3.3.6/css/bootstrap.min.css"" rel="stylesheet">
	<link href="https://cdn.bootcdn.net/ajax/libs/animate.css/3.2.3/animate.css" rel="stylesheet">
    <link href="https://cdn.bootcdn.net/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet">
	<link rel="stylesheet" type="text/css" href="../../static/css/public.css" />
	<style type="text/css">
		li{
			text-indent: 2em;
			padding: 5px 0;
		}
	</style>
</head>
<body>
	<!-- 回到顶部 -->
	<div class="topBtn">
		<a href="#top">
			<i class="fa fa-long-arrow-up"></i>
		</a>
	</div>
	<!--右边内容-->
	<div id="app" class="main animated fadeInRight">
		<div class="shadow">
			<div class="Table" v-cloak id="top">
				<div class="TableRow" v-for="(el,index) in list">
					<a class="RowLeft" :href="'#'+el.id"
					:title="el.name"
					>{{el.name}}</a>
					<span class="RowRight">{{el.explain}}</span>
				</div>
			</div>
			<div>
				<h4 id="use">创建image</h4>
				<pre>
	<svg xmlns="http://www.w3.org/2000/svg" version="1.1">
	    <image  xlink:href="../img/th.jpg" width="300" />
	</svg>		
	
	&lt;svg xmlns="http://www.w3.org/2000/svg" version="1.1"&gt;
		&lt;image  xlink:href="../img/th.jpg" width="300" /&gt;
	&lt;/svg&gt;	
	//设置好宽度，高度auto
				</pre>
			</div>
			<div>
				<div title="开始" draggable="true"
				  style="width: 200px;height: 150px;cursor: move;"
				 class="item">
					<svg class="">
						<g> 
							<g transform="translate(0.5,0.5)">
								<ellipse cx="18" cy="18" rx="15" ry="9" 
								fill="#fff" stroke="#000" stroke-width="1" cursor="move">
								</ellipse>
							</g> 
						</g>
					</svg>
					<!-- <div style="width: 200px;height: 150px;background: green;">
						
					</div> -->
				</div>
				<div style="background-color: #ccc;cursor: progress;height: 500px;width: 1000px;">
					
				</div>
				<div>
				  <p id="source" @dragstart="dragstart_handler" draggable="true">
				    Select this element, drag it to the Drop Zone and then release the selection to move the element.
				  </p>
				</div>
				<div id="target" draggable="true" @drop="drop_handler" @dragover="dragover_handler">Drop Zone</div>
			</div>
		</div>
	</div>
	<!--页面加载进度条-->
	<script src="https://cdn.bootcdn.net/ajax/libs/pace/0.5.0/pace.min.js"></script>
	<script src="https://cdn.bootcdn.net/ajax/libs/vue/2.5.17/vue.js" type="text/javascript" charset="utf-8"></script>
	<script type="text/javascript">
		var app = new Vue({
			el: "#app",
			data: function() {
				return {
					list: [
						{ name: "创建image",id: "use",explain: '用image创建svg图片'},
					]
				}
			},
			mounted() {
				document.addEventListener("dragover", function( event ) {
				    // 阻止默认动作
				    event.preventDefault();
				}, false);
			},
			methods:{
				dragstart_handler(ev) {
				  console.log("dragStart: dropEffect = " + ev.dataTransfer.dropEffect + " ; effectAllowed = " + ev.dataTransfer.effectAllowed);
				
				  // Add this element's id to the drag payload so the drop handler will
				  // know which element to add to its tree
				  ev.dataTransfer.setData("text", ev.target.id);
				  ev.dataTransfer.effectAllowed = "move";
				},
				
				drop_handler(ev) {
				  console.log("drop: dropEffect = " + ev.dataTransfer.dropEffect + " ; effectAllowed = " + ev.dataTransfer.effectAllowed);
				  ev.preventDefault();
				
				  // Get the id of the target and add the moved element to the target's DOM
				  var data = ev.dataTransfer.getData("text");
				  ev.target.appendChild(document.getElementById(data));
				},
				
				dragover_handler(ev) {
				  console.log("dragOver: dropEffect = " + ev.dataTransfer.dropEffect + " ; effectAllowed = " + ev.dataTransfer.effectAllowed);
				  ev.preventDefault();
				  // Set the dropEffect to move
				  ev.dataTransfer.dropEffect = "move"
				}
			}
		})
	</script>
</body>

</html>